<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<script src="{yun:}$config.sy_weburl{/yun}/js/jquery-1.8.0.min.js?v={yun:}$config.cachecode{/yun}"></script>
<script src="js/admin_public.js?v={yun:}$config.cachecode{/yun}" language="javascript"></script>
<link href="{yun:}$config.sy_weburl{/yun}/js/layui/css/layui.css?v={yun:}$config.cachecode{/yun}" rel="stylesheet">

<link href="images/reset.css?v={yun:}$config.cachecode{/yun}" rel="stylesheet" type="text/css" />
<link href="images/system.css?v={yun:}$config.cachecode{/yun}" rel="stylesheet" type="text/css" />
<link href="images/table_form.css?v={yun:}$config.cachecode{/yun}" rel="stylesheet" type="text/css" />

<title>后台管理</title>
</head>
<body class="body_ifm">
<form action="index.php?m=admin_message&c=show" method="post" id='checkform'>
  <input type="hidden" name="userid" id="userid" value="">
  <input type="hidden" name="pytoken" value="{yun:}$pytoken{/yun}">
</form>


<div class="infoboxp">

  <div class="table-list">
    <div class="admin_table_border">
      <iframe id="supportiframe"  name="supportiframe" onload="returnmessage('supportiframe');" style="display:none"></iframe>
      <form action="index.php"  target="supportiframe" name="myform" method="get" id='myform' class="layui-form">

        <div class="layui-form-item">
          <label class="layui-form-label">选择业务员进行转移客户</label>
          <div class="layui-input-inline">
            <select name="new_uid" lay-filter="new_uid" id="new_uid">
              <option value="">请选择业务员</option>
              {yun:}foreach from=$new_uid item=r{/yun}
              <option value="{yun:}$r['uid']{/yun}">{yun:}$r['name']{/yun}</option>
              {yun:}/foreach{/yun}
            </select>
          </div>
        </div>

        <table width="100%">
			<thead>
				<tr class="admin_table_top">
					<th style="width:20px;">
						<label for="chkall"><input type="checkbox" id='chkAll'  lay-filter="chkall"/></label>
					</th>
					<th align="left"> 
						{yun:}if $smarty.get.t=="uid" && $smarty.get.order=="asc"{/yun}
							<a href="index.php?m=crm_salesman_list&c=shift_company&uid={yun:}$uid{/yun}&order=desc&t=uid">用户ID<img src="images/sanj.jpg"/></a> 
						{yun:}else{/yun} 
							<a href="index.php?m=crm_salesman_list&c=shift_company&uid={yun:}$uid{/yun}&order=asc&t=uid">用户ID<img src="images/sanj2.jpg"/></a> 
						{yun:}/if{/yun}
					</th>
					<th align="left">企业名称</th>
					<th class="admin_table_th_bg">操作</th>
				</tr>
			</thead>

          <tbody>
          {yun:}foreach item=v key=key from=$company{/yun}
          <tr {yun:}if ($key+1)%2=='0'{/yun}class="admin_com_td_bg"{yun:}/if{/yun} id="list{yun:}$v.uid{/yun}">
            <td width="20"><input type="checkbox" value="{yun:}$v.uid{/yun}" class="check_all"  name='comids' onclick='unselectall()' rel="del_chk" email="{yun:}$v.email{/yun}" moblie="{yun:}$v.telphone{/yun}" style="margin-left:5px;;"/></td>
           
            <td align="left" class="td1" style=" width:60px;">{yun:}$v.uid{/yun}</td>

            <td align="left" style="width:400px;">
            {yun:}$v.name{/yun}
            </td>
        
            <td>
            <div class="admin_new_bth_c">
             <a href="javascript:void(0);" class="admin_new_c_bth admin_new_c_bthsd" pid="{yun:}$v.uid{/yun}" onclick="shift('{yun:}$v.uid{/yun}');">转移</a>
            </div>
            </td>
          </tr>
          {yun:}/foreach{/yun}
          <tr style="background:#f1f1f1;">
            <td align="left">
              <input type="checkbox" id='chkAll2' lay-filter="chkall"/>
              <label for="chkAll2">全选</label>
            </td>
            <td>
              &nbsp;
			        <input class="admin_button" type="button" name="delsub" value="批量转移企业客户" onClick="assignMulti();" />
			      </td>
            <td class="digg">{yun:}$pagenav{/yun}</td>
            <td></td>
          </tr>
          </tbody>
        </table>
        <input type="hidden" name="pytoken" id='pytoken' value="{yun:}$pytoken{/yun}">
      </form>
    </div>
  </div>
</div>

<script src="{yun:}$config.sy_weburl{/yun}/js/layui/layui.js?v={yun:}$config.cachecode{/yun}" language="javascript"></script>
<script src="{yun:}$config.sy_weburl{/yun}/js/layui/phpyun_layer.js?v={yun:}$config.cachecode{/yun}"></script>
<script>

layui.use(['layer', 'form'], function(){
  var layer = layui.layer
  ,form = layui.form
  ,$ = layui.$;

  form.on('checkbox(chkall)', function(data){
    $(".check_all").prop("checked", this.checked);
    form.render();
  });
  
});

var salesmanId = '{yun:}$uid{/yun}';

//分配企业客户给业务员
function shift(comid)
{
  if($("#new_uid").val() == ''){
    layer.msg('请先选择业务员');
    return false;
  }

  $.post('index.php?m=crm_salesman_list&c=ajax_shift',
    { uid : salesmanId, comid : comid, new_uid : $("#new_uid").val(), pytoken: $("#pytoken").val()},
    function(data)
    {
      if(data == 1){
        layer.msg('转移成功', 2, 9, function(){
          parent.layer.closeAll();
          window.location = window.location;
        });
      }
    }
  );

}

//批量分配企业客户给业务员
function assignMulti()
{
  // comids
  var chk_value =[];
  $('input[name="comids"]:checked').each(function(){
    chk_value.push($(this).val());
  }); 

  if(chk_value.length == 0){
    layer.msg('还未选择任何企业');
    return false;
  }

  var comid = chk_value.join(',');
  shift(comid);
}

</script>

</body>
</html>
